const COLUMNS = [{
		prop: "documentNumber",
		label: "档案号",
		width: "80"
	},{
		prop: "customername",
		label: "公司名称",
		width: "80"
	}
]


let app = new Vue({
	el: "#app",
	
	data() {
		return {
			fits: ['fill', 'contain', 'cover', 'none', 'scale-down'],
			src: 'https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg',
			saverules: {
				type: [{
					required: true,
					message: '请输入类型名称',
					trigger: 'blur'
				} ]
			},
			leftbar_show: true,
			// 添加、编辑标识
			tableHeight: window.innerHeight - 180,
			tablecolums: COLUMNS,
			queryForm: {
				documentNumber: "",
				companyname: "",
				pageNo: 1, // 当前页码
				pagesize: 100, // 每页记录数
				pagesizes: [10, 20, 50, 100]
			},

			pagetotal: 0,
			pagetotaltemp: 0,
			pickerOptions: {
				shortcuts: [{
					text: '最近一周',
					onClick(picker) {
						const end = new Date();
						const start = new Date();
						start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
						picker.$emit('pick', [start, end]);
					}
				}, {
					text: '最近一个月',
					onClick(picker) {
						const end = new Date();
						const start = new Date();
						start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
						picker.$emit('pick', [start, end]);
					}
				}, {
					text: '最近三个月',
					onClick(picker) {
						const end = new Date();
						const start = new Date();
						start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
						picker.$emit('pick', [start, end]);
					}
				}]
			},
			// 多选
			multipleSelection: [],
			pagedatatemp: [], // 当前页结果集
			pagedata: [], // 当前页结果集
			loaded: false,
		}
	},
	methods: {

		toolAction(acName) {
			if (acName == "添加") {
				this.add()
			}
		},



		// 添加
		add() {
			
		},


		// 显示侧边栏
		showLeftBar() {

			if (this.leftbar_show)
				return this.leftbar_show = false
			if (!this.leftbar_show)
				return this.leftbar_show = true

		},
		// 表格多选 
		handleSelectionChange(val) {
			this.multipleSelection = val;
		},
		handleRemove(file, filelist) {},

		handleAvatarSuccess(res, file, filelist) {},



	
		start() {
			this.queryForm.pageNo = 1
			this.query()
		},

		// 查询
		async query() {
			// 显示加载框
			const loading = this.$loading(LOAD_STYLE);
			try {
				let res = await axios.post('api/document/querylist', this.queryForm);
				if (res.code === 200) {
					this.pagedata = res.data;
					this.pagetotal = res.total;
					
					this.$message.success(res.message);

				} else {
					this.$message.error(res.message);
				}
			} catch (e) {
				this.$message.error('请求出错！', e.message);
			}

			// 关闭加载框
			loading.close();
		},


		selectionChange(selection) {
			this.selection = selection
		},


		// 编辑


		// 设定表格当前页
		handleCurrentPageChange(selectedPageNo) {
			this.queryForm.pageNo = selectedPageNo
			// 加载数据页
			this.query()
		},
		//设定每页记录数
		handleSizeChange(val) {
			this.queryForm.pagesize = val
			// 加载数据页
			this.query()
		},
clickTable(row, expandedRows) {
	console.log(row)
	console.log(expandedRows)
	}

		


	},

	async mounted() {
		// 自动调整表格高度
		window.onresize = () => {
			return (() => {
				this.tableHeight = window.innerHeight - 180
			})()
		}


	},


});
